import { getAreaObj } from '@/utils/util'
import { getStore } from '@/utils/store'
const userInfo = getStore('userInfo') || {}
const authAreaArr = [userInfo.authProvince, userInfo.authCity, userInfo.authArea, userInfo.authStreet, userInfo.authCommunity].filter(Boolean)

export const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共1个：',
					children: [
						{
							label: '《紧急呼叫工单信息导入模板》',
							link: true,
							url: 'view_callRecord_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入基础信息',
			description: '',
			uploadTip: '紧急呼叫工单信息导入',
			active: 2,
			url: 'view_callRecord_import',
			code: 4002,
			rules: [
				{
					label: '导入规则说明:',
					children: [{ label: '(1)导入模式为“覆盖导入”，待导入的信息会覆盖平台已存在的' }],
				},
			],
		},
	],
}

const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '所属街道',
			prop: 'streetName',
		},
		{
			label: '所属社区',
			prop: 'communityName',
		},
		{
			label: '呼叫类型',
			prop: 'type',
			custome: 'tag',
			dicData: [
				{
					label: '呼入',
					value: 1,
				},
				{
					label: '呼出',
					value: 2,
				},
			],
		},
		{
			label: '呼叫对象',
			prop: 'callerName',
			type: 'input',
		},
		{
			label: '联系方式',
			prop: 'callerIdcardno',
			type: 'input',
		},
		{
			label: '身份证号',
			prop: 'callerIdcardno',
			type: 'input',
		},
		{
			label: '需求内容',
			prop: 'requestType',
			custome: 'tag',
			dicData: [
				{
					label: '紧急救援',
					value: 1,
				},
				{
					label: '咨询服务',
					value: 2,
				},
				{
					label: '服务转介',
					value: 3,
				},
				{
					label: '投诉监管',
					value: 4,
				},
				{
					label: '客户回访',
					value: 5,
				},
			],
		},
		{
			label: '坐席',
			prop: 'monitorName',
			type: 'input',
		},
		{
			label: '处理内容',
			prop: 'handleContent',
			type: 'input',
		},
		{
			label: '评价',
			prop: 'evaluateStar',
			custome: 'tag',
			dicData: [
				{
					label: '未评价',
					value: 0,
				},
				{
					label: '非常满意',
					value: 1,
				},
				{
					label: '满意',
					value: 2,
				},
				{
					label: '一般',
					value: 3,
				},
				{
					label: '服务态度不满意',
					value: 4,
				},
				{
					label: '处理结果不满意',
					value: 5,
				},
			],
			span: 8,
		},
		{
			label: '应答时间',
			prop: 'answerTime',
		},
		{
			label: '结束时间',
			prop: 'endTime',
		},
		{
			label: '处理时间',
			prop: 'handleTime',
		},
		{
			label: '操作',
			prop: 'menu',
			width: 100,
			fixed: 'right',
		},
	],
}

const detailConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '呼叫类型',
			prop: 'type',
			type: 'select',
			dicData: [
				{
					label: '呼入',
					value: 1,
				},
				{
					label: '呼出',
					value: 2,
				},
			],
			span: 12,
		},
		{
			label: '呼叫客户电话',
			prop: 'callerPhone',
			span: 12,
		},
		{
			label: '呼叫客户名称',
			prop: 'callerName',
			span: 12,
		},
		{
			label: '呼叫客户身份证号',
			prop: 'callerIdcardno',
			span: 12,
		},
		{
			label: '坐席名称',
			prop: 'monitorName',
			span: 12,
		},
		{
			label: '需求类型',
			prop: 'requestType',
			type: 'select',
			dicData: [
				{
					label: '紧急救援',
					value: 1,
				},
				{
					label: '咨询服务',
					value: 2,
				},
				{
					label: '服务转介',
					value: 3,
				},
				{
					label: '投诉监管',
					value: 4,
				},
				{
					label: '客户回访',
					value: 5,
				},
			],
			span: 12,
		},
		{
			label: '应答时间',
			prop: 'answerTime',
			span: 12,
		},
		{
			label: '结束时间',
			prop: 'endTime',
			span: 12,
		},
		{
			label: '处理内容',
			prop: 'handleContent',
			span: 12,
		},
		{
			label: '处理时间',
			prop: 'handleTime',
			span: 12,
		},
		{
			label: '评价',
			prop: 'evaluateStar',
			type: 'select',
			dicData: [
				{
					label: '未评价',
					value: 0,
				},
				{
					label: '非常满意',
					value: 1,
				},
				{
					label: '满意',
					value: 2,
				},
				{
					label: '一般',
					value: 3,
				},
				{
					label: '服务态度不满意',
					value: 4,
				},
				{
					label: '处理结果不满意',
					value: 5,
				},
			],
			span: 12,
		},
	],
}

const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '所属街道社区',
			prop: 'areas',
			type: 'AplidAreaSelect',
			administrationPid: authAreaArr[authAreaArr.length - 1],
			span: 8,
		},
		{
			label: '呼叫类型',
			prop: 'type',
			type: 'select',
			dicData: [
				{
					label: '呼入',
					value: 1,
				},
				{
					label: '呼出',
					value: 2,
				},
			],
			span: 8,
		},
		{
			label: '呼叫对象',
			prop: 'callerName',
			type: 'input',
			span: 8,
		},
		{
			label: '联系方式',
			prop: 'callerIdcardno',
			type: 'input',
			span: 8,
		},
		{
			label: '身份证号',
			prop: 'callerIdcardno',
			type: 'input',
			span: 8,
		},
		{
			label: '需求内容',
			prop: 'requestType',
			type: 'select',
			dicData: [
				{
					label: '紧急救援',
					value: 1,
				},
				{
					label: '咨询服务',
					value: 2,
				},
				{
					label: '服务转介',
					value: 3,
				},
				{
					label: '投诉监管',
					value: 4,
				},
				{
					label: '客户回访',
					value: 5,
				},
			],
			span: 8,
		},
		{
			label: '坐席',
			prop: 'monitorName',
			type: 'input',
			span: 8,
		},
		{
			label: '处理内容',
			prop: 'handleContent',
			type: 'input',
			span: 8,
		},
		{
			label: '评价',
			prop: 'evaluateStar',
			type: 'select',
			dicData: [
				{
					label: '未评价',
					value: 0,
				},
				{
					label: '非常满意',
					value: 1,
				},
				{
					label: '满意',
					value: 2,
				},
				{
					label: '一般',
					value: 3,
				},
				{
					label: '服务态度不满意',
					value: 4,
				},
				{
					label: '处理结果不满意',
					value: 5,
				},
			],
			span: 8,
		},
		{
			label: '应答时间',
			prop: 'answerTime',
			type: 'date',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
		},
		{
			label: '结束时间',
			prop: 'endTime',
			type: 'datetime',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
		},
		{
			label: '处理时间',
			prop: 'handleTime',
			type: 'datetime',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
		},
	],
}

export const baseConfig: any = {
	pageName: '呼叫中心工单',
	addLabel: '',
	dictcodes: [],
	rowKey: 'id',
  importLabel:'导入',
	// tipLabel: 'projectName',
	api: {
		index: 'view_callRecords_page',
		detail: 'view_callRecords_id',
		import: 'view_callRecord_import',
	},
	auth: {
		index: 'view_callRecords_page',
		detail: 'view_callRecords_id',
		import: 'view_callRecord_import',
	},

	menuBtn: [
		{
			icon: 'detail',
			label: '查看',
			type: 'primary',
			operate: 'detail',
			auth: 'view_callRecords_id',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	beforeOnLoadFormate: async (query) => {
		return new Promise((resolve, reject) => {
			const areaIds = [...authAreaArr, ...(query.areas || [])]
			const areasObj: any = getAreaObj(areaIds, '')

			resolve({
				...query,
				...areasObj,
				areas: undefined,
			})
		})
	},
	searchConfig,
	tableConfig,
	detailConfig,
	importConfig,
}
